home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 1157 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.7 KB

  1. Path: fido.asd.sgi.com!austern
  2. From: Nico Josuttis <nico@bredex.de>
  3. Newsgroups: comp.std.c++
  4. Subject: auto_ptr problem?: delete or delete[]
  5. Date: 18 Apr 1996 09:42:52 PDT
  6. Organization: Bredex GmbH
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <199604181455.QAA12877@bredex.bredex.de>
  9. Reply-To: nico@bredex.de
  10. NNTP-Posting-Host: isolde.mti.sgi.com
  11. X-Original-Date: Thu, 18 Apr 1996 16:55:50 +0200
  12. Apparently-To: nico@bredex.de
  13. Apparently-To: std-c++@ncar.ucar.edu
  14. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  15.     iQBVAwUBMXZxDUy4NqrwXLNJAQFj1QH+OGwGfE3GnP/7f5oSYvvxMGOq68Nsnd7M
  16.     JzqWzGKAWA9n72mc5D3pySUp5x0eQpqT3ik5/rmqgLQrhooJ0Qfhdg==
  17.     =U6dR
  18. Originator: austern@isolde.mti.sgi.com
  19.  
  20. In a tutorial a student asked a very good question i think:
  21. How can auto_ptr imagine which delete to use.
  22. Consider:
  23.  int* p = new int;
  24. and
  25.  int* p = new int[10];
  26. should result in different delete operations.
  27. But if I let auto_ptr do the job, how does it know
  28. which one to use?
  29.  
  30. Isn't it a BIG design problem ?
  31. Reading the DWP it calls delete (without [])
  32. what would be wrong in many cases since
  33. using new for arrays is probaly made very often.
  34.  
  35. I fear we need two kind of auto_ptr, don't we?
  36. -- 
  37. Nico                             address: BREDEX GmbH, Nicolai Josuttis
  38. email:   nico@bredex.de                   Fallersleber-Tor-Wall 23
  39. phone:   +49 531 24330-0                  D-38100 Braunschweig
  40. fax:     +49 531 24330-99                 Germany
  41. ---
  42. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  43.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  44.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  45.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  46.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  47. ]
  48.